package multiThread;

/*
 * Creating multiple thread using same memory/object
 */

class A implements Runnable {
	public void run() {
		for (int i = 0; i < 30; i++) {
			System.out.println(Thread.currentThread().getName() + " I = " + i);
			try {
				Thread.sleep(100);
			} catch (InterruptedException e) {
			}
		}
	}
}

public class MyThread7 {
	public static void main(String args[]) {
		A obj1 = new A();

		// Creation of thread.
		Thread t1 = new Thread(obj1);
		Thread t2 = new Thread(obj1);
		Thread t3 = new Thread(obj1);

		t1.setName("1st");
		t2.setName("2nd");
		t3.setName("3rd");
		// Thread is made runnable.
		t1.start();
		t2.start();
		t3.start();
	}
}